;(function (window) {

var pageLogic = {
    init: {
        before: function () {
            var columns = [
                {field: "checked", checkbox: true},
                {field: "num", title: "序号", width: 5, align: "center", formatter: common.formatter.index},
                {field: "id", visible: false},
                {field: "gcdmc", title: "观测点", width: 80, align: "center"},
                {field: "cmch", title: "船名船号", width: 80, align: "center"},
                {field: "aissbh", title: "九位码", width: 80, align: "center"},
                {field: "zzdw", title: "准载吨位(吨)", width: 80, align: "center"},
                {field: "tgsj", title: "通过时间", width: 80, align: "center", formatter: pageLogic.formatter.buildDate},
                {field: "sxx", title: "上下行", width: 80, align: "center", formatter:pageLogic.formatter.buildSxx},
                {field: "sjlx", title: "数据来源", width: 80, align: "center", formatter:pageLogic.formatter.buildSjlx},

            ];

            common.initTable(columns);
        },

        layout: function() {
            common.layout();
        },
        after: function () {
            //创建模态窗口
            common.modal(pageLogic.initData.modalParams[0], {
            rules: {
            },

            messages: {}
            });


            window.initDatePicker({id: "startTimeSearch", type: "day", formatter: "yyyy-mm-dd"});
            window.initDatePicker({id: "endTimeSearch", type: "day", formatter: "yyyy-mm-dd"});



        },
        //页面控件事件绑定(一般为按钮的事件绑定)
        events: function () {
            common.registerEvents();
        },

        load: function () {
            common.search();
        }
    }
};

pageLogic.formatter = {
    buildDate: function (value, row) {
        return value.substr(0, 10);
    },
    buildSxx: function (value,row) {
        var result = "";
        if (value == "1") {
            result = "上行";
        } else if (value == "2") {
            result = "下行";
        } else {
            result = "未知";
        }
        return result;
    },
    buildSjlx: function (value, row) {
        var result = "";
        if (value == "1") {
            result = "基站上报";
        } else if (value == "2") {
            result = "AIS上报";
        } else {
            result = "未知";
        }
        return result;
    },
};

window.pageLogic = pageLogic;
})(window);
